package gam.n1.skills.i;

import gam.n1.areas.Area;
import gam.n1.ent.AEntity;
import gam.n1.skills.BaseSkill;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

public class Thunder extends BaseSkill {
    private final Location l; // 闪电击落的位置
    private final double r; // 范围
    public Thunder(@NotNull Area a, UUID u, String n, @NotNull Location initL, double initR) {
        super(a,u,n);
        this.l = initL;
        this.r = initR < 1 ? 1 : initR;
    }

    @Override
    protected void _do() {
        if (area().isRunning()){
            World var1 = area().getAreaInWorld();
            List<LivingEntity> var3 = var1.getNearbyEntities(l, r, r, r).stream().filter(var2 -> !(var2 instanceof Player) && AEntity.class.isAssignableFrom(var2.getClass())).map(var4 -> ((LivingEntity) var4)).collect(Collectors.toList());
            var3.forEach(var5 -> var5.damage(damage()));
            var1.strikeLightningEffect(l);
        }
    }
}
